<?php
/**
 * The template for displaying Tag template.
 *
 * @file      tag.php
 * @package   phunuchungminh.com
 * @author    Chinh Tran
 * 
 **/
?>
<?php get_header();?>



<div class="content">
	<div class="wrapper">
			<div class="container">
				<div class="left-block full-width-md full-width-sm full-width-xs">
                <?php if ( have_posts() ) { $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; global $wp_query;
                        $total_pages = $wp_query->max_num_pages; $tag = get_queried_object(); ?>
					<h1 class="search-tag-title">Bài viết liên quan đến chủ đề: <span class="keyword"> "<?php echo single_cat_title('') ?>"</span> </h1>
					<ul class="portrait-items-list re_search">
                        <?php
    						while ( have_posts() ) {
    							the_post();?>
    							
                                <li>
            						<div class="news-item"> 
            							<a href="<?php esc_url(the_permalink())?>" style="background:url(<?php echo get_bg_image(get_the_ID());?>) no-repeat; background-size: cover;" class="img"><img src="<?php echo get_bg_image(get_the_ID());?>" alt="<?php the_title() ?>"/></a>
            							<div class="right-info">
            								<a href="<?php esc_url(the_permalink())?>"> <?php the_title() ?> </a>
            								<span class="time"> <?php echo get_the_date( 'H:i | d/m/Y', get_the_ID() ); ?></span>
            								<p class="summary"> <?php echo substr(get_the_excerpt(), 0,148); ?>..  </p>
            							</div>
            							
            						</div>
            					</li>
                                <div class="clear"> </div>
                            
						<?php }
						  //ap_pagination();
						?>
					
				    </ul>
				<div class="block-row">
					 <?php if($paged < $total_pages ) {?>
					       <a href="<?php echo esc_url( home_url( '/' ) ).'chu-de/'.$tag->slug.'/'.($paged + 1); ?>" class="view_more_listnews">Xem thêm</a>
                    <?php } else { ?>
                            <a  class="view_more_listnews">Không còn tin để thiển thị</a>
                    <?php } ?>
                    <?php wp_paginate(); ?>
					<!--div class="paginator">
						<ol class="wp-paginate">
							<li><a href="#" class="next"><img src="images/arrow-left.png"></a></li>
							<li><span class="page current">1</span></li>
							<li><a href="#" title="2" class="page">2</a></li>
							<li><a href="#" title="3" class="page">3</a></li>
							<li><a href="#" title="4" class="page">4</a></li>
							<li><a href="#" title="5" class="page">5</a></li>
							<li><a href="#" class="next"><img src="images/arrow-right.png"></a></li>
						</ol>
                        
					</div-->
				</div>
					<?php } else {  ?>
                        <h1 class="search-tag-title">Không có bài viết nào được tìm thấy</h1>
                    <?php }?>
				</div><!--End left-block-->
				<div class="right-block hidden-md hidden-sm hidden-xs">
					<div class="block-row">
						<div class="items-list">
							<a href="#"><img src="<?php echo get_template_directory_uri() ?>/images/banner_300x250.png" alt="fadf"/></a>
						</div>
					</div><!--End block-row-->
					<div class="clear"> </div>
					<div class="block-row">
						<div class="trend-tag">
						<div class="trend-head">
							<h2> XU HƯỚNG ĐỌC TIN</h2>
						</div>
						<div class="clear"> </div>
						<div class="trend-content fslider carousel" id="slider">
							<ul class="slides">
								<?php $tags = trend_tags(); ?>
                                <?php foreach($tags as $tag){?>
                                    <li style="background: <?php echo get_random_color(); ?>; margin-right: 5px !important;"> <a href="<?php echo get_tag_link($tag->term_id); ?> "> <?php echo $tag->name; ?> </a> </li>
                                <?php }?>
							</ul>
						</div>
					</div><!--End trend tag-->
					</div>
					<div class="clear"> </div>
					<div class="block-row cate-right-bar">
						<h1> <span>TOP</span> ẨM THỰC</h1>
						<ul class="items-list">
                             <?php $args = array(
                                        'category_name'      => 'am-thuc',
                                        'posts_per_page'    => 6,
                                        'orderby'           => 'meta_value_num',
                                        'orderby'           => 'date', 
                                        'order'             => 'DESC'
                                   );
                                   $the_query = new WP_Query($args);
                                   // The Loop
                                   if ( $the_query->have_posts() ) {
                                        while ( $the_query->have_posts() ) {
                                            $the_query->the_post();?>
                                            <li>
                								<div class="news-item" > 
                									<a href="<?php esc_url(the_permalink())?>" style="background:url(<?php echo get_bg_image(get_the_ID());?>) no-repeat; background-size: cover;" class="img_rblock">
                										<img src="<?php echo get_bg_image(get_the_ID());?>" alt="<?php the_title() ?>"/>
                									</a>
                									<a href="<?php esc_url(the_permalink())?>"> <?php the_title() ?> </a>
                								</div>
                							</li>
                							<div class="clear"> </div>
                                            
                                                    
                            <?php  }} wp_reset_postdata(); ?>
                        	
						</ul>
						<a href="<?php echo esc_url( home_url( '/' ) ); ?>chuyen-muc/am-thuc" class="crb-view-more">Xem thêm <span> Ẩm Thực</span></a>
					</div><!--End block-row-->
					<div class="clear"> </div>
					<div class="block-row">
						<div class="items-list">
							<a href="#"><img src="<?php echo get_template_directory_uri() ?>/images/banner_300x250.png" alt="fadf"/></a>
						</div>
					</div><!--End block-row-->
					<div class="clear"> </div>
					<div class="block-row cate-right-bar">
						<h1> <span>TOP</span> GIA ĐÌNH</h1>
						<ul class="items-list">
                            <?php $args = array(
                                        'category_name'      => 'gia-dinh',
                                        'posts_per_page'    => 6,
                                        'orderby'           => 'meta_value_num',
                                        'orderby'           => 'date', 
                                        'order'             => 'DESC'
                                   );
                                   $the_query = new WP_Query($args);
                                   // The Loop
                                   if ( $the_query->have_posts() ) {
                                        while ( $the_query->have_posts() ) {
                                            $the_query->the_post();?>
                                            <li>
                								<div class="news-item" > 
                									<a href="<?php esc_url(the_permalink())?>" style="background:url(<?php echo get_bg_image(get_the_ID());?>) no-repeat; background-size: cover;" class="img_rblock">
                										<img src="<?php echo get_bg_image(get_the_ID());?>" alt="<?php the_title() ?>"/>
                									</a>
                									<a href="<?php esc_url(the_permalink())?>"> <?php the_title() ?> </a>
                								</div>
                							</li>
                							<div class="clear"> </div>
                                            
                                                    
                            <?php  }} wp_reset_postdata(); ?>
                        		
						</ul>
						<a href="<?php echo esc_url( home_url( '/' ) ); ?>chuyen-muc/gia-dinh" class="crb-view-more">Xem thêm <span> Gia Đình</span></a>
					</div><!--End block-row-->
					<div class="clear"> </div>
					<div class="block-row">
						<div class="items-list">
							<a href="#"><img src="<?php echo get_template_directory_uri() ?>/images/banner_300x250.png" alt="fadf"/></a>
						</div>
					</div><!--End block-row-->
					<div class="clear"> </div>
					
				</div><!--End right-block-->	
			</div><!--End container-->
		</div><!--End wrapper-->
</div><!--End content-->

<?php get_footer(); ?>